package com.study.book.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.study.book.common.R;
import com.study.book.pojo.Product;
import com.study.book.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "商品接口")
@RestController
@RequestMapping("/app/product")
public class ProductController {

    @Autowired
    private ProductService productService;


    @ApiOperation("获取图书馆商品数据")
    @GetMapping("/getProductList/{libraryId}")
    public R list(@PathVariable("libraryId") String libraryId) {
        LambdaQueryWrapper<Product> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Product::getLibraryId,libraryId);
        return R.ok(productService.list(lambdaQueryWrapper));
    }

    @ApiOperation("获取商品数据")
    @GetMapping("/getProductListById/{productId}")
    public R listProduct(@PathVariable("productId") String productId) {
        return R.ok(productService.getById(productId));
    }
}
